package com.hex.ds.hdrs.period.job.controller;

import com.hex.bigdata.hbda.annotation.Log;
import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.common.page.PageData;
import com.hex.ds.hdrs.period.job.po.HisBitch;
import com.hex.ds.hdrs.period.job.service.HisBitchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@Api(tags = "历史数据批次")
@RequestMapping("/api/jobHisBitch")
public class HisBitchController {

    @Autowired
    private HisBitchService hisBitchService;

    /**
     * @Method: selectPages <br>
     * @Param: [hisBitch, page] <br>
     * @Return: org.springframework.http.ResponseEntity<java.lang.Object> <br>
     * @Description：分页查询历史数据批次<br>
     * @Author： gc.zuo<br>
     * @Date： 2021/6/3 15:33 <br>
     * @Version： V1.0<br>
     */
    @GetMapping("/selectPages")
    @ApiOperation("分页查询历史数据批次")
    public ResponseEntity<Object> selectPages(HisBitch hisBitch, Page page) {
        log.info("进入了【HisBitchController】的selectPages方法");
        PageData pageData = new PageData(this.hisBitchService.selectPages(hisBitch, page),
                page);
        return new ResponseEntity<>(pageData, HttpStatus.OK);
    }

    /**
     * @Method: reduction <br>
     * @Param: [hisBitch] <br>
     * @Return: org.springframework.http.ResponseEntity<java.lang.Object> <br>
     * @Description：还原历史数据<br>
     * @Author： gc.zuo<br>
     * @Date： 2021/6/3 15:34 <br>
     * @Version： V1.0<br>
     */
    @Log("还原任务历史批次")
    @ApiOperation("还原任务历史批次")
    @PostMapping(value = "/reduction")
    public ResponseEntity<Object> reduction(@RequestBody HisBitch hisBitch) {
        log.debug("还原任务历史批次【HisBitchController.reduction】参数：{}", hisBitch.toString());
        this.hisBitchService.reduction(hisBitch);
        return new ResponseEntity<>("还原成功", HttpStatus.OK);
    }
}
